package vfs.persist.association.impl;


import java.sql.Connection;
import vfs.filter.VFSFilter;
import vfs.obj.entity.VFSNodeType;
import vfs.obj.entity.VFSNode;
import vfs.persist.association.VFSNodeToNodeTypeManager;
import vfs.persist.entity.build.impl.VFSNodeTypeBuilder;
import vfs.persist.entity.build.impl.VFSNodeBuilder;
import java.util.Iterator;

/**
 *
 * @author Matthew Eavenson <durandal@uga.edu>
 */
public class VFSNodeToNodeTypeManagerImpl implements VFSNodeToNodeTypeManager{
    
    private VFSAssociationManagerImpl<VFSNode, VFSNodeType> am;
    
    public VFSNodeToNodeTypeManagerImpl(Connection conn){
        am = new VFSAssociationManagerImpl<VFSNode, VFSNodeType>(conn, new VFSNodeBuilder(), 
                                                 new VFSNodeTypeBuilder(), 
                                        "vfsNode", null, "type");
    }
    
    @Override
    public Iterator<VFSNode> getNodes(VFSNodeType nodeType, VFSFilter filter){
        return am.findTM1(nodeType, filter);
    }
    
    @Override
    public VFSNodeType getNodeType(VFSNode node){
        return am.findUM1(node);
    }
    
    @Override
    public void setNodeType(VFSNode node, VFSNodeType nodeType){
        am.persistM1(node, nodeType);
    }
    
}
